<?php

class SiteController extends Controller
{
  public function filters()
  {
    return array(
        'accessControl', // perform access control for CRUD operations
    );
  }

  public function accessRules()
  {
    return array(
        array('allow', // allow all users to access 'index' and 'view' actions.
            'actions' => array('index'),
            'users' => array('*'),
        ),

        array('deny',
            'users' => array('*'),
        ),
    );
  }

  /**
   * This is the default 'index' action that is invoked
   * when an action is not explicitly requested by users.
   */
  public function actionIndex()
  {
    $this->render('index');
  }

  /**
   * This is the action to handle external exceptions.
   */
  public function actionError()
  {
    if ($error = Yii::app()->errorHandler->error) {
      if (Yii::app()->request->isAjaxRequest)
        echo $error['message'];
      else
        $this->render('error', $error);
    }
  }

  public function actionTestAjax()
  {
    echo CJSON::encode(array('status' => 1, 'message' => 'ok'));
  }

}